using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

/// <summary>
/// Summary description for ShoppingCart
/// </summary>
public class ShoppingCart
{
    public List<Item> ItemCollection = new List<Item>();
    public void Add(Item item)
    {
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            if (item.IDSanPham == ItemCollection[i].IDSanPham)
            {
                ItemCollection[i].SoLuong += item.SoLuong;
                return;
            }
        }
        ItemCollection.Add(item);
    }
    public void Delete(Item item)
    {
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            if (item.IDSanPham  == ItemCollection[i].IDSanPham )
            {
                ItemCollection.RemoveAt(i);
                return;
            }
        }
    }
    public void Update(Item item)
    {
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            if (item.IDSanPham == ItemCollection[i].IDSanPham )
            {
                ItemCollection[i].SoLuong = item.SoLuong ;
                return;
            }
        }
    }
    public int Total()
    {
        int total = 0;
        for (int i = 0; i < ItemCollection.Count; i++)
        {
            total += ItemCollection[i].GiaBan;
        }
        return total;
    }
}
